cmake_minimum_required(VERSION 3.24.2)

project(unit_test VERSION 0.1)

set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_INSTALL_PREFIX sandbox)

# cmake dependencies
include(FetchContent)
FetchContent_Declare(
        googletest
        GIT_REPOSITORY https://github.com/google/googletest.git
        GIT_TAG release-1.12.1
        FIND_PACKAGE_ARGS NAMES GTest
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

add_library(factorial factorial.cxx)

add_executable(factorial_test factorial_test.cxx)
target_link_libraries(factorial_test GTest::gtest_main factorial)

add_executable(queue_test queue_test.cxx)
target_link_libraries(queue_test GTest::gtest_main)

add_executable(advance_topic_test advance_topic_test.cxx)
target_link_libraries(advance_topic_test GTest::gtest_main)

add_executable(assertion_test assertion.cxx)
target_link_libraries(assertion_test GTest::gtest_main)

add_executable(run_all_test main.cxx factorial_test.cxx queue_test.cxx)
target_link_libraries(run_all_test GTest::gtest factorial)

add_executable(typed_test typed_test.cxx prime_tables.h)
target_link_libraries(typed_test GTest::gtest_main)

# The last two lines enable CMake’s test runner to discover the tests included in the binary, using the GoogleTest CMake module.
enable_testing()
include(GoogleTest)
gtest_discover_tests(factorial_test)
gtest_discover_tests(queue_test)
